package com.hdl.servlet.news;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.hdl.entity.Article;
import com.hdl.service.ArticleService;
import com.hdl.service.impl.ArticleServiceImpl;

@WebServlet("/zixun-perv.let")
public class NewsNextServlet extends HttpServlet {

	Logger log = LoggerFactory.getLogger(this.getClass());
	private ArticleService articleService = new ArticleServiceImpl();
	private Article article = new Article();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		Long id = Long.valueOf(req.getParameter("articleId"));
		/* log.debug("id={}",id); */
		article = articleService.selectPrevious(id);
		/* log.debug(JSON.toJSONString(article)); */
		req.setAttribute("article", article);
		req.getRequestDispatcher("newdetail.jsp").forward(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
	
}
